home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / Misc / FaceFromPICT.c next >
Encoding:
Text File  |  1994-07-26  |  1.3 KB  |  51 lines  |  [TEXT/KAHL]

  1. // C translation by Adam Wight
  2.  
  3. #include "SAT.h"
  4.  
  5. FacePtr GetFaceFromPICT (int colorPICTid,int bwPICTid,int maskPICTid);
  6.  
  7. /*No error checking yet!*/
  8.  
  9. FacePtr GetFaceFromPICT (int colorPICTid,int bwPICTid,int maskPICTid) {
  10.         Rect bounds;
  11.         PicHandle thePICT, maskPICT;
  12.         FacePtr theFace;
  13.         GrafPtr savePort;
  14.         GDHandle saveGD;
  15.  
  16.         GetPort(savePort);
  17.         if (colorFlag) saveGD = GetGDevice();
  18.  
  19.         /*Get PICTs*/
  20.         if (gSAT.initDepth > 1) thePICT = GetPicture(colorPICTid);
  21.         else thePICT = GetPicture(bwPICTid);
  22.  
  23.         maskPICT = GetPicture(maskPICTid);
  24.         bounds = (*thePICT)->picFrame;
  25.         OffsetRect(&bounds, -bounds.left, -bounds.top); /* Unnecessary? I think NewFace does this for us. /Ingemar */
  26.  
  27.         /*Create face*/
  28.         theFace = NewFace(&bounds);
  29.  
  30.         /*Draw in the face*/
  31.         SetPortFace(theFace);
  32.         DrawPicture(thePICT, &bounds);
  33. //        FrameRect(&bounds);
  34.         SetPortMask(theFace);
  35.         DrawPicture(maskPICT, &bounds);
  36. //        FrameRect(&bounds);
  37.         /*Tell SAT that we are done*/
  38.         ChangedFace(theFace);
  39.  
  40.         /*Get rid of the PICTs*/
  41.         ReleaseResource((Handle)thePICT);
  42.         ReleaseResource((Handle)maskPICT);
  43.  
  44.         /*Return the face.*/
  45.  
  46.         if (colorFlag) SetGDevice(saveGD);
  47.         SetPort(savePort);
  48.  
  49.         return theFace;
  50. }
  51.